import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

// 导入axios
import axios from 'axios'
axios.defaults.baseURL = 'https://m.maizuo.com'
import { Toast } from 'vant';
import 'vant/es/toast/style';
// 请求拦截
axios.interceptors.request.use(
    config => {
        config.headers = {
            "X-Client-Info": '{"a":"3000","ch":"1002","v":"5.0.4","e":"1598087896889693885431809","bc":"110100"}',
            "X-Host": "mall.film-ticket.film.list",
          };
          // 在发送请求之前做些什么
          return config;
    },
    error => {
        // 对请求错误做些什么
        Toast("网络请求错误，请检查网络！")
        return Promise.reject(error);
    }
)
// 相应拦截
axios.interceptors.response.use(res => {
    if (res.data.msg === "ok") {
      Toast("成功返回数据！");
      return res.data;
    } else {
      Toast("数据错误反馈，请检查输入！")
    }
  }, err => {
    console.log(err);
    Toast("网络请求错误，请检查网络！")
  });
// 立即执行函数
//   (async () => {
//     const res = await axios.get("gateway?cityId=110100&pageNum=1&pageSize=10&type=1&k=8591124");
//     console.log(res);
//   })();

createApp(App).use(store).use(router).mount('#app')
